<div class="layui-tab layui-tab-fixed layui-tab-brief">
	<ul class="layui-tab-title">
		<li class="layui-this">基本配置</li>
	</ul>
	<div class="layui-tab-content editor-form-node">
		<div class="layui-tab-item layui-show">
			<form class="layui-form">
				<div class="layui-form-item">
					<label class="layui-form-label">节点名称</label>
					<div class="layui-input-block">
						<input type="text" name="value" placeholder="请输入节点名称" value="{{=d.value}}" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">数据源</label>
					<div class="layui-input-block">
						<select name="datasourceId"></select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">收件人</label>
					<div class="layui-input-block">
						<input type="text" name="mailboxmail" placeholder="如果多个收件人使用','隔开" autocomplete="off" class="layui-input input-default"
							value="{{=d.data.object.mailboxmail}}">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">抄送人</label>
					<div class="layui-input-block">
						<input type="text" name="mailboxcc" placeholder="如果多个抄送人使用','隔开" autocomplete="off" class="layui-input input-default" value="{{=d.data.object.mailboxcc}}">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">暗抄送人</label>
					<div class="layui-input-block">
						<input type="text" name="mailboxbcc" placeholder="如果多个抄送人使用','隔开" autocomplete="off" class="layui-input input-default" value="{{=d.data.object.mailboxbcc}}">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">邮箱标题</label>
					<div class="layui-input-block">
						<input type="text" name="mailboxsubject" placeholder="请输入邮箱标题" autocomplete="off" class="layui-input input-default"
							value="{{=d.data.object.mailboxsubject}}">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">发送内容</label>
					<div class="layui-input-block" style="height:200px;" placeholder="支持html" codemirror="mailboxcontext" data-value="{{=d.data.object.mailboxcontext}}"></div>
				</div>
				{{# layui.each(d.data.object['enclosure-name'],function(index,output){ }}
				<hr>
				<div class="draggable" draggable="true">
					<div class="layui-form-item layui-form-relative">
						<i class="layui-icon layui-icon-close function-remove"></i> <label class="layui-form-label">附件名称</label>
						<div class="layui-input-block">
							<input type="text" name="enclosure-name" placeholder="请输入附件名称" autocomplete="off" class="layui-input array"
								value="{{=d.data.object['enclosure-name'][index]}}">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">附件</label>
						<div class="layui-input-block array" codemirror="enclosure-value" placeholder="仅支持bety[]类型,实例:${file.bytes('C:\1.jpg')}" data-value="{{=d.data.object['enclosure-value'][index]}}"></div>
					</div>
				</div>
				{{# }) }}
				<hr>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn mailbox-enclosure-add" type="button">添加一个附件</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
<script>
	$(".mailbox-enclosure-add").on("click",function(){
		$(this).parent().parent().before('<div class="draggable" draggable="true"><div class="layui-form-item layui-form-relative"><i class="layui-icon layui-icon-close function-remove"></i><label class="layui-form-label">附件名称</label><div class="layui-input-block"><input type="text" name="enclosure-name" placeholder="请输入附件名称" autocomplete="off" class="layui-input array"></div></div><div class="layui-form-item"><label class="layui-form-label">附件</label><div class="layui-input-block array" codemirror="enclosure-value" placeholder="仅支持bety[]类型,实例:${file.bytes(\'C:\\1.jpg\')}"></div></div></div>');
		renderCodeMirror();
	});
	$.ajax({
		url : 'mail/list',
		data : {
			limit : 9999
		},
		success : function(data){
			var mails = data.records;
			for(var i=0,len = mails.length;i<len;i++){
				var mail = mails[i];
				$('select[name=datasourceId]').append('<option value="'+mail.id+'">'+mail.name+'</option>');
			}
			layui.form.render();
			var selectMailId = '{{=d.data.object.datasourceId}}';
			if(selectMailId != ''){
				$('.layui-form-select dd[lay-value='+selectMailId+']').trigger('click');
			}
		}
	});
</script>
